<?php

use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\grid\GridView;
use yii\bootstrap\Modal;
use yii\helpers\ArrayHelper;
use kartik\select2\Select2;
use yii\web\JsExpression;
use app\common\Functions;
use app\models\OrderResumes;
use app\models\Order;

    /**
     * @var yii\web\View $this
     * @var amnah\yii2\user\Module $module
     * @var array $actions
     */
    global $regionTypes2;
    global $prodAttrCodes;
    $regionTypes2 = $regionTypes;
    $module = $this->context->module;



    $prodAttrCodes=[];


    // 增加展示的字段
    $columns = [];

    $i = 'id';

    // id
    $columns[$i]['attribute'] = 'id';
    $columns[$i]['options'] = ['style'=>'width:30px'];





    foreach ($attrSpecs as $attrSpec)
    {
        $prodAttr = $attrSpec->attrSpecs;




        if ($attrSpec->grid_show_flag!=1)
        {
            continue;
        }

        $i=$prodAttr->attr_field_name;
        $columns[$i]['label'] = $prodAttr->attr_spec_name;
        $prodAttrCodes[$i] = $prodAttr->attr_spec_id;
        $a = $prodAttr->attr_spec_id;
        $attr_spec_type_id = $prodAttr->attr_spec_type_id;

        $columns[$i]['value']   = function($model, $key, $index, $column)use ($a, $attr_spec_type_id)
        {
            if ($model->externalAttrs)
            {
                foreach ($model->externalAttrs  as $attrInst)
                {


                    if ($a == $attrInst->attr_spec_id)
                    {
                        if ($attr_spec_type_id==3)
                        {
                            return Functions::getDomainsName('attr_spec',$a,  $attrInst->content);
                        }
                        else if($attr_spec_type_id==4)
                        {
                            return $attrInst->content . '-'.$attrInst->content2 ;
                        }

                        return $attrInst->content;

                    }
                }
            }

            return  ' ';

        };

        $width = '120px';
        if($prodAttr->attr_spec_width)
        {
            $width = 'width:' . $prodAttr->attr_spec_width . 'px';
        }

        $columns[$i]['options'] = ['style'=>$width];

    }

    $subStaffGroups =  Functions::getDomains('staff','sub_staff_group');
    $subStaffGroups[''] = '全部';
    ksort($subStaffGroups);

    // 业务组
    $i='sub_staff_group';
    $columns[$i]['label'] = '业务片区';
    $columns[$i]['attribute'] = 'sub_staff_group';
    $columns[$i]['options'] = ['style'=>'width:60px'];
    $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'sub_staff_group',$subStaffGroups,['style'=>'height:24px']);//
    $columns[$i]['content']   = function($model)
    {

        return Functions::getDomainsName('staff','sub_staff_group',  $model->dealUsers->sub_staff_group);

    };

//    $subStaffGroups =  Functions::getDomains('order','state');
//
//    ksort($subStaffGroups);



    $str2 = substr($now_url,0,20);
    if($str2=='/prod/order/allorder'){
        $i='state_info';
        //订单类型
        $columns[$i]['label'] = '信息状态';
        $columns[$i]['format'] = 'raw';//格式化输出
        $columns[$i]['attribute'] = 'state_info';
        $columns[$i]['options'] = ['style'=>'width:60px'];
        $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'state_info',['30005'=>'需要','30006'=>'作废'],[]);//'style'=>'height:33px'
        $columns[$i]['value']   = function($model) use($orderStatesd)
        {

            return $orderStatesd[$model->state_info];

        };

   };



    // 客户来源
    $i='cust_source_id';
    $columns[$i]['label'] = '来源';
    $columns[$i]['attribute'] = 'cust_source_id';
    $columns[$i]['options'] = ['style'=>'width:60px;'];
    //$columns[$i]['filter'] = Html::activeTextInput($searchModel, 'orderTypeName', ['class'=>'form-control']);
    //$columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'cust_source_id',[],['style'=>'height:15px']);
    $columns[$i]['value']   = function($model) use($custSources)
    {

        return $custSources[$model->custs->cust_source_id]['show_name'];
        //return $domainSources[$model->custs->cust_source_id];

    };
    $custSourceType[''] = '全部';
    ksort($custSourceType);
    $columns[$i]['filter'] = $custSourceType;

    //对象类型
    $i='object_id';
    $columns[$i]['label'] = '客户';
    $columns[$i]['attribute'] = 'object_id';
    $columns[$i]['format'] = 'raw';
    $columns[$i]['options'] = ['style'=>'width:80px'];
    $columns[$i]['value']   = function($model) use ($objectTypes,$encrypted,$authority)
    {

        $urlOrderView = [];
        // 如果是客户
        if ($model->object_type_id==1)
        {

            $urlOrderView[]='/prod/cust/view';
            $urlOrderView['id'] = $model->object_id;
            $urlOrderView['attr_type_spec_id'] = 20001;
            $urlOrderView['prod_spec_name'] = '客户';
            $urlOrderView['order_id'] = $model->id;

            //$model->accNbr = '1214212';
            if ($encrypted)
            {
                // 如果是自己处理的房源无需打码
                if ($model->staff_id == Yii::$app->user->id)
                {
                    $urlOrderView['acc_nbr'] = $model->custs->tel;
                }
                else
                {
                    $urlOrderView['acc_nbr'] =  '*******';

                    // 如果权限有值,则可以查询自己分组下的内容
                    if ($authority)
                    {
                        if ($authority<10)
                        {
                            if ($model->dealUsers->staff_group==$authority)
                            {
                                $urlOrderView['acc_nbr'] = $model->custs->tel;
                            }
                        }
                        elseif($model->dealUsers->sub_staff_group==$authority)
                        {
                            $urlOrderView['acc_nbr'] = $model->custs->tel;
                        }
                    }
                }
            }
            else
            {
                $urlOrderView['acc_nbr'] = $model->custs->tel;
            }

//$objectTypes[$model->object_type_id] . ' : ' .
            return Html::a(  $model->custs->cust_name ,
                $urlOrderView,
                ['title' => "订单主体"]);

            //return $objectTypes[$model->object_type_id] . ' : ' . $model->custs->cust_name;
        }

        $urlOrderView[] = '/prod/prodinst/view' ;
        $urlOrderView['id'] = $model->object_id;
        $urlOrderView['attr_type_spec_id'] = $model->prodInsts->prod_spec_id;
        $urlOrderView['prod_spec_name'] = '楼盘';
        $urlOrderView['order_id'] = $model->id;


        return Html::a( $objectTypes[$model->object_type_id] . ' : '  . $model->parentProdInsts->prod_name . ' '   .$model->prodInsts->prod_name,
            $urlOrderView,
            ['title' => "订单主体"]);

        //return $objectTypes[$model->object_type_id] . ' : '  . $model->parentProdInsts->prod_name . ' '   .$model->prodInsts->prod_name;


    };

    $i='remark';
    //订单类型
    $columns[$i]['label'] = '备注';
    $columns[$i]['attribute'] = 'remark';
    $columns[$i]['options'] = ['style'=>'width:180px'];
    $columns[$i]['filter'] = Html::activeTextInput($searchModel, 'remark', ['class'=>'form-control']);//,'style'=>'height:33px'

    $i='modify_date';
    //更新时间
    $columns[$i]['label'] = '跟进时间';
    $columns[$i]['attribute'] = 'modify_date';
    $columns[$i]['options'] = ['style'=>'width:80px'];
    $columns[$i]['content']   = function($model)
    {
        return   substr($model->modify_date, 5, 11) ;



    };


    $i='state';
    //订单类型
    $columns[$i]['label'] = '状态';
    $columns[$i]['attribute'] = 'state';
    $columns[$i]['options'] = ['style'=>'width:60px'];

    $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'state',$orderStates,['style'=>'height:24px;width:50px;']);
    $columns[$i]['content']   = function($model) use($orderStates)
    {

        //查询是否有回访记录
        $pay=OrderResumes::find()->where(['AND',['=','resumes_type_id',20012] ,['=','order_id',$model->id] ])->count();
        $payd=Order::find()->where(['AND',['=','state',30002] ,['=','id',$model->id] ])->count();
//          echo date('w');0周天 6周六
        if($pay>=1 || $payd>=1){//有回访记录伙已成交
            return  $orderStates[$model->state];
        }else{//没回访的
            $today = strtotime (date("y-m-d h:i:s")); //当前时间（转时间戳）
            $todays=strtotime($model->modify_date);//系统录入的 修改 时间
            $day=Functions::getWeekend();
            $todayd=round(($today-$todays)/86400)-$day; //60s*60min*24h  ceil()向上取整


            if($todayd>3){//超过3天   变红
                return  "<small class=\"label pull-right bg-red\">超</small> <i class='text-red'>" . $orderStates[$model->state] ."</i> "  ;
            }else {
                return   $orderStates[$model->state];
            }
        }



    };




    // 如果是公盘，不显示经办人，因为没有经办
//    if(!$public_flag  )
//    {
        $i='staff_id';
        //经办人
        $columns[$i]['label'] = '经办人';
        $columns[$i]['attribute'] = 'staff_id';
        $columns[$i]['options'] = ['style'=>'width:90px'];
        //$columns[$i]['filter'] = Html::activeTextInput($searchModel, 'user_name', ['class'=>'form-control']); // ,'style'=>'height:33px'
        $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'staff_id',$model_staff_name,['class'=>'form-control','style'=>'width:55px;']);
        $columns[$i]['content']   = function($model)
        {

                return  $model->dealUsers->staff_name ;

        };
//    }

    $model_d[''] = '全部';//区域添加全部的下拉
    ksort($model_d);
    $i = 'region_id';
    //更新时间
    $columns[$i]['label'] = '区县';
    $columns[$i]['attribute'] = 'region_id';
    $columns[$i]['options'] = ['style'=>'width:80px;'];
    //$columns[$i]['filter'] = Html::activeTextInput($searchModel, 'region_name', ['class'=>'form-control']);
    $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'region_name',$model_d,['style'=>'height:24px']);//'style'=>'height:33px'
//    $columns[$i]['filter']   = $form->field($searchModel, "region_name") ->dropDownList( $model, [
//    'prompt'=>'--请选择区域--']);
    $columns[$i]['content']   = function($model) use($regions)
    {
        return     $regions[$model->externalAttrs2->content];

    };





    $i='create_staff_id';
    //名称
    $columns[$i]['label'] = '录入人';
    $columns[$i]['attribute'] = 'create_staff_id';
    $columns[$i]['options'] = ['style'=>'width:80px'];
    //$columns[$i]['filter'] = Html::activeTextInput($searchModel, 'create_staff_name', ['class'=>'form-control']);//,'style'=>'height:33px'
    $columns[$i]['filter'] = Html::activeDropDownList($searchModel, 'create_staff_id',$model_staff_name,['class'=>'form-control','style'=>'width:55px;']);
    $columns[$i]['content']   = function($model)
    {
        return $model->users->staff_name   ;
    };

    $i='input_time';
    //更新时间
    $columns[$i]['label'] = '录入日期';
   // $columns[$i]['format'] = ['date', 'yyyy-MM-dd HH:mm'];
    $columns[$i]['attribute'] = 'input_time';
    $columns[$i]['options'] = ['style'=>'width:80px'];


    $columns[$i]['content']   = function($model)
    {
        return  substr($model->input_time,5,11) ;
        // date('Y-m-d H:i:s', $model->modify_date);
    };


    $i='early_time';
    //更新时间
    $columns[$i]['label'] = '录入天数';
    $columns[$i]['attribute'] = 'safe';
    $columns[$i]['options'] = ['style'=>'width:80px'];
    $columns[$i]['content']   = function($model)
    {
        $date= time();
        $sum=strtotime($model->create_date)  ;
        $sun=$date-$sum;
        return   round(($sun)/3600/24)  . '天' ;

    };

    // 使用膜版进行二次加工
    $columns2 = Functions::getFormatColumns($customs, $columns,$searchModel);
//    $ii = 0;
//    $columns2 = [];
//    foreach ($customs as $custom)
//    {
//        if (!$columns[$custom->attr_field_name])
//        {
//            continue;
//        }
//
//        // 如果定义为不显示也是不进行对应的处理
//        if ($custom->hide_flag!=1)
//        {
//            continue;
//        }
//        $columns[$custom->attr_field_name]['label'] = $custom->show_name;
//
//        $columns2[$ii] = $columns[$custom->attr_field_name];
//        $columns2[$ii]['label'] = $custom->show_name;
//        if ($columns2[$ii]['label'] =='需求面积')
//        {
//            $columns2[$ii]['filter'] = Html::activeTextInput($searchModel, 'need_area', ['class'=>'form-control']);//,'style'=>'height:33px'
//        }
//        $columns2[$ii]['options'] = ['style'=>'width:' . $custom->attr_spec_width . 'px'];
//        $ii++;
//        //$custom
//    }




if ($black!=1)
{
    // 如果是公盘 而且状态为不为作废，则可以抢单
    if ($public_flag  )
    {
       // $i++;
        //操作选项
       // $columns[$i]['class']   = 'app\common\grid\ActionColumn';
        $columns2[$ii]['options'] = ['style'=>'width:100px'];

        $columns2[$ii]['content']   = function($model)
        {
            // 如果订单状态为作废不能抢
            if($model->state == 30003  )
            {
                return '';
            }

            $btns = [];

            $btnBegin = Html::a( '抢', ['grab', 'id'=>$model->id ], ['class' => "btn btn-xs btn-warning",'label'=>'抢单', 'title' => '抢单']);
            $btns[]   = Html::a( '抢', ['grab', 'id'=>$model->id ], [ 'label'=>'抢单', 'title' => '抢单']);
//            $btns[]   = Html::a('黑名单',
//                '#' ,
//                ['id' => 'activity-black-list-link',
//                    'class' => "activity-black-list-link",
//                    'data-toggle'=>'modal',
//                    'data-target'=>'#black-list-modal',
//                    'label'=>'标记为黑名单', 'title' => '黑名单',
//                    'data-order-id'=>$model->id]);

            return Functions::getActionDropdownContext($btnBegin, $btns);
           // return  substr($model->create_date,0,16) ;
            // date('Y-m-d H:i:s', $model->modify_date);
        };


    }
    else
    {
        //$i++;
        //操作选项
       // $columns[$i]['class']   = 'app\common\grid\CustActionColumn';
        $columns2[$ii]['options'] = ['style'=>'width:110px'];

//        return Functions::getActionDropdownContext($btnBegin, $btns);

        $columns2[$ii]['content']   = function($model) use ($prodSpecName, $now_url,$encrypted,$authority)
        {
            // 如果订单状态为作废不能抢
            if( $model->state == 30003 && $model->state_info == 30006){
                $btns = [];
                $btnBegin = Html::a('恢复信息', '#',
                    ['class' => "btn btn-xs btn-warning"]);
                $btns[]   = Html::a( '恢复', '#', ['class' => 'recover','data-order-id'=>$model->id, 'label'=>'恢复', 'title' => '恢复']);
                return Functions::getActionDropdownContext($btnBegin, $btns);

            }elseif($model->state == 30003  )
            {
                if( Yii::$app->user->id==6){
                    $btns = [];
                    $btnBegin = Html::a('信息部', '#',
                        ['class' => "btn btn-xs btn-warning"]);
                    $btns[] = Html::a('信息部作废', '#',
                        ['id' => 'order-link',
                            'class' => "order-link",
                            'data-toggle' => 'modal',
                            'data-target' => '#order-modal',
                            'label' => '订单作废', 'title' => '订单作废',
                            'data-order-id' => $model->id,
                            'data-attr_type_spec_id' => $model->object_type_id,
                            'data-last_url' => $now_url]);
                    return Functions::getActionDropdownContext($btnBegin, $btns);
                }else{
                    $btns = [];

                    $btnBegin =Html::a( '查看进度',['/prod/cust/view', 'id'=>$model->object_id,   'attr_type_spec_id'=> 20001 , 'order_id'=>$model->id,'timeline'=>'timeline' ], [ 'class' => "btn btn-xs btn-warning ",'label'=>'跟进记录', 'title' => '跟进记录']);

                    return Functions::getActionDropdownContext($btnBegin, $btns);
                }


            }

            $btns = [];

//
            $btnBegin =Html::a( '查看进度',['/prod/cust/view', 'id'=>$model->object_id,   'attr_type_spec_id'=> 20001 , 'order_id'=>$model->id,'timeline'=>'timeline' ], [ 'class' => "btn btn-xs btn-warning ",'label'=>'跟进记录', 'title' => '跟进记录']);

//
            $btns[]   = Html::a( '查看跟进记录',['/prod/cust/view', 'id'=>$model->object_id,   'attr_type_spec_id'=> 20001 , 'order_id'=>$model->id,'timeline'=>'timeline' ], [ 'label'=>'跟进记录', 'title' => '跟进记录']);


            $btns[]   = Html::a( '进度更新', '#', ['id' => 'activity-handling-resumes-link',
                'class' => "activity-handling-resumes-link",
                'data-toggle'=>'modal',
                'data-target'=>'#handling-resumes-modal',
                'label'=>'更新进度', 'title' => '更新进度',
                'data-order-id'=>$model->id,
                'data-last_url' =>$now_url]);


            if ($encrypted)
            {
                // 如果是自己处理的房源无需打码
                if ($model->staff_id == Yii::$app->user->id)
                {
                    $btns[]   = Html::a( '变更负责人',   '#',
                        ['id' => 'activity-modify-uesr-link',
                            'class' => "activity-modify-uesr-link",
                            'data-toggle'=>'modal',
                            'data-target'=>'#modify-uesr-modal',
                            'label'=>'变更负责人', 'title' => '变更负责人',
                            'data-order-id'=>$model->id,
                            'data-last_url' =>$now_url]);
                    $btns[]   = Html::a( '需求更新',  ['/prod/cust/update',
                        'id'=>$model->custs->id,
                        'order_id'=>$model->id,
                        'attr_type_spec_id'=> $model->object_type_id,
                        'prod_spec_name' => $prodSpecName,
                        'last_url' =>$now_url],
                        [ 'label'=>'修改', 'title' => '修改']);
                }
                else
                {


                    // 如果权限有值,则可以查询自己分组下的内容
                    if ($authority)
                    {
                        if ($model->dealUsers->sub_staff_group==$authority)
                        {
                            $btns[]   = Html::a( '变更负责人',   '#',
                                ['id' => 'activity-modify-uesr-link',
                                    'class' => "activity-modify-uesr-link",
                                    'data-toggle'=>'modal',
                                    'data-target'=>'#modify-uesr-modal',
                                    'label'=>'变更负责人', 'title' => '变更负责人',
                                    'data-order-id'=>$model->id,
                                    'data-last_url' =>$now_url]);
                            $btns[]   = Html::a( '需求更新',  ['/prod/cust/update',
                                'id'=>$model->custs->id,
                                'order_id'=>$model->id,
                                'attr_type_spec_id'=> $model->object_type_id,
                                'prod_spec_name' => $prodSpecName,
                                'last_url' =>$now_url],
                                [ 'label'=>'修改', 'title' => '修改']);
                        }
                        elseif($model->dealUsers->staff_group==$authority){
                            $btns[]   = Html::a( '变更负责人',   '#',
                                ['id' => 'activity-modify-uesr-link',
                                    'class' => "activity-modify-uesr-link",
                                    'data-toggle'=>'modal',
                                    'data-target'=>'#modify-uesr-modal',
                                    'label'=>'变更负责人', 'title' => '变更负责人',
                                    'data-order-id'=>$model->id,
                                    'data-last_url' =>$now_url]);
                            $btns[]   = Html::a('黑名单',
                                '#' ,
                                ['id' => 'activity-black-list-link',
                                    'class' => "activity-black-list-link",
                                    'data-toggle'=>'modal',
                                    'data-target'=>'#black-list-modal',
                                    'label'=>'标记为黑名单', 'title' => '黑名单',
                                    'data-order-id'=>$model->id,
                                    'data-last_url' =>$now_url]);
                        }
                    }


                }

            }
            else
            {

                $btns[]   = Html::a( '变更负责人',   '#',
                    ['id' => 'activity-modify-uesr-link',
                        'class' => "activity-modify-uesr-link",
                        'data-toggle'=>'modal',
                        'data-target'=>'#modify-uesr-modal',
                        'label'=>'变更负责人', 'title' => '变更负责人',
                        'data-order-id'=>$model->id,
                        'data-last_url' =>$now_url]);
                $btns[]   = Html::a( '需求更新',  ['/prod/cust/update',
                    'id'=>$model->custs->id,
                    'order_id'=>$model->id,
                    'attr_type_spec_id'=> $model->object_type_id,
                    'prod_spec_name' => $prodSpecName,
                    'last_url' =>$now_url],
                    [ 'label'=>'修改', 'title' => '修改']);

            }




//            $btns[]   = Html::a( '修改属性',   '#',
//                ['id' => 'activity-modify-update-order-link',
//                    'class' => "activity-modify-update-order-link",
//                    'data-toggle'=>'modal',
//                    'data-target'=>'#modify-update-order-modal',
//                    'label'=>'变更负责人', 'title' => '变更负责人',
//                    'data-id'=>$model->custs->id,
//                    'data-order_id'=>$model->id,
//                    'data-attr_type_spec_id'=>$model->object_type_id,
//                    'data-prod_spec_name'=>$prodSpecName,
//                    'data-last_url'=>$now_url]);





            $btns[]   = Html::a( '日期更新',   '#',
                ['id' => 'date_changed',
                    'class' => "date_changed",
                    'data-toggle'=>'modal',
                    'data-target'=>'#date_changed_modal',
                    'label'=>'日期修改', 'title' => '日期修改',
                    'data-order-id'=>$model->id,
                    'data-attr_type_spec_id'=> $model->object_type_id ,
                    'data-last_url' =>$now_url]);



            $btns[]   = Html::a( '标记无效',   '#',
                ['id' => 'activity-cancel-order-link',
                    'class' => "activity-cancel-order-link",
                    'data-toggle'=>'modal',
                    'data-target'=>'#cancel-order-modal',
                    'label'=>'订单无效', 'title' => '订单无效',
                    'data-order-id'=>$model->id,
                    'data-attr_type_spec_id'=> $model->object_type_id ,
                    'data-last_url' =>$now_url]);

            $str2 = substr($now_url,0,20);
            if($str2=='/prod/order/allorder') {
                $btns[] = Html::a('信息部无效', '#',
                    ['id' => 'order-link',
                        'class' => "order-link",
                        'data-toggle' => 'modal',
                        'data-target' => '#order-modal',
                        'label' => '订单无效', 'title' => '订单无效',
                        'data-order-id' => $model->id,
                        'data-attr_type_spec_id' => $model->object_type_id,
                        'data-last_url' => $now_url]);
            }

//            $btns[]   = Html::a( '作废',['/prod/order/cancel', 'id'=>$model->id,   'attr_type_spec_id'=> $model->object_type_id ], [ 'label'=>'删除', 'title' => '删除']);


            return Functions::getActionDropdownContext($btnBegin, $btns);

        };


    }
}


?>

<?php
        //产生列表 和 按钮的插件
        echo GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'layout' => "{items}{summary}{pager}",
            'options'=>['id'=>'grid', 'class'=>'col-sm-12'],
            'tableOptions'=>[ 'class'=>'table table-bordered table-striped dataTable'],
            'columns' => $columns2,
        ]);




$js = <<<JS
jQuery('.activity-black-list-link').on('click',function() {
    $('.document-black-list-form').remove();
    $.get(
        '/prod/order/blacklist',          
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url') 
        },
        function (data) {
      
            $('#black-list-modal').find('.modal-dialog').html(data);
        }  
    );
});
JS;
$this->registerJs($js);

//跟新进度
$js = <<<JS
jQuery('.activity-handling-resumes-link').on('click',function() {
    $('.document-handling-resumes-form').remove();
    $.get(
        '/prod/order/handling',          
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url') 
        },
        function (data) {
             
            $('#handling-resumes-modal').find('.modal-dialog').html(data);
          
        }  
    );
});
JS;
$this->registerJs($js);//将一段js代码写入registerJs

//作废
$js = <<<JS
jQuery('.activity-cancel-order-link').on('click',function() {
    $('.document-cancel-order-form').remove();
    $.get(
        '/prod/order/cancel',          
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url') ,
             attr_type_spec_id: $(this).data('attr_type_spec_id') 
        },
        function (data) {
            $('#cancel-order-modal').find('.modal-dialog').html(data);
           
        }  
    );
});
JS;
$this->registerJs($js);

//信息部作废
$js = <<<JS
jQuery('.order-link').on('click',function() {
    $('.document-cancel-order-form').remove();
    $.get(
        '/prod/order/information',
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url') ,
             attr_type_spec_id: $(this).data('attr_type_spec_id')
        },
        function (data) {
            $('#order-modal').find('.modal-dialog').html(data);

        }
    );
});
JS;
$this->registerJs($js);

//恢复
$js = <<<JS
jQuery('.recover').on('click',function() {

    $.get(
        '/prod/order/updates',
        {
            order_id: $(this).data('order-id')

        },
        function (data) {
            location.reload();//刷新
        }
    );
});
JS;
$this->registerJs($js);



//日期修改
$js = <<<JS

jQuery('.date_changed').on('click',function() {
    //$('.document-modify-uesr-form').remove();
    $.get(
        '/prod/order/inputtime',
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url')

        },
        function (data) {

            $('#date_changed_modal').find('.modal-dialog').html(data);


        }
    );

});
JS;
$this->registerJs($js);




$js = <<<JS

jQuery('.activity-modify-uesr-link').on('click',function() {
    $('.document-modify-uesr-form').remove();
    $.get(
        '/prod/order/modifyuser',          
        {
            order_id: $(this).data('order-id') ,
             last_url: $(this).data('last_url') 
        },
        function (data) {
        
            $('#modify-uesr-modal').find('.modal-dialog').html(data);

        }  
    );
});
JS;
$this->registerJs($js);


$js = <<<JS

jQuery('.activity-modify-update-order-link').on('click',function() {
    $('.document-modify-update-order-form').remove();
    $.get(
        '/prod/cust/create',          
        {
            id: $(this).data('id') ,
            order_id: $(this).data('order_id') ,
            attr_type_spec_id: $(this).data('attr_type_spec_id') ,
            prod_spec_name: $(this).data('prod_spec_name') ,
            last_url: $(this).data('last_url') 
        },
        function (data) {
        
            $('#modify-update-order-modal').find('.modal-dialog').html(data);
      
            
        }  
    );
});
JS;
$this->registerJs($js);





// Pjax::end();
Modal::begin([
    'id' => 'black-list-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">创建</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
]);
Modal::end();

Modal::begin([
    'id' => 'handling-resumes-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">更新订单状态</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

Modal::begin([
    'id' => 'modify-uesr-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">修改负责人</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

Modal::begin([
    'id' => 'modify-update-order-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">修改订单</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();


Modal::begin([
    'id' => 'cancel-order-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">订单作废</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

Modal::begin([
    'id' => 'order-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">信息部确定作废</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

Modal::begin([
    'id' => 'date_changed_modal',
    'class' => 'modal modal-primary',

    'options' => [
        'tabindex' => false
    ],
]);
Modal::end();

?>



